// ist8310_wrapper.cpp

#include "ist8310_wrapper.h"
#include "ist8310.h"

extern "C"
{
  // C接口实现
  I2CDevice *create_i2c_device(const char *device)
  {
    return new LinuxI2C(device);
  }

  void destroy_i2c_device(I2CDevice *device)
  {
    delete device;
  }

  IST8310 *create_ist8310(I2CDevice *device)
  {
    return new IST8310(*device);
  }

  void destroy_ist8310(IST8310 *sensor)
  {
    delete sensor;
  }

  void ist8310_get_mag_vector(IST8310 *sensor, int16_t *x, int16_t *y, int16_t *z)
  {
    auto mag_vector = sensor->getMagVector();
    *x = mag_vector[0];
    *y = mag_vector[1];
    *z = mag_vector[2];
  }

  int16_t ist8310_get_temperature(IST8310 *sensor)
  {
    return sensor->getTemperature();
  }
}
